package com.sbr.esbmonitor.servicemix;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlRootElement;

import com.sbr.esbmonitor.model.xml.servers.ServerType;

@XmlRootElement
public class Server implements Serializable {

	private static final long serialVersionUID = 1L;
	private String hostName = "localhost";
	private String port = "1099";
	private String userName = "smx";
	private String password = "smx";
	
	private int id;
	
	private String label;

	public Server() {
		
	}
	
	public Server(ServerType serverType) {
		this.label = serverType.getLabel();
		this.hostName = serverType.getHostName();
	}

	public String getHostName() {
		return hostName;
	}

	public void setHostName(String hostName) {
		this.hostName = hostName;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getJmxUrl() {
		//TODO refactorer la chaine
		return "service:jmx:rmi:///jndi/rmi://"+hostName+":"+port+"/karaf-root";
	}
	
	public ServerType toXML() {
		ServerType server = new ServerType();
		server.setLabel(label);
		server.setHostName(hostName);
		return server;
	}

	@Override
	public String toString() {
		return "Server [id=" + id + ", label=" + label + ", hostName="
				+ hostName + ", port=" + port + ", userName=" + userName
				+ ", password=" + password + "]";
	}
	
	
	
}
